package com.songkun.template.ui.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.songkun.template.config.AppController;
import com.songkun.template.databinding.ActivityBaseBinding;
import com.songkun.template.utils.eventObj.VoidEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;


/**
 * @描述:　所有Activity基类
 * @项目名: AndroidTemplate
 * @包名: com.songkun.template.ui.base
 * @类名:
 * @作者: soongkun
 * @创建时间: 2016/4/29 13:16
 */

public abstract class BaseActivity extends AppCompatActivity {

    protected ActivityBaseBinding mBasebinding;
    private AppController mAppController;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mAppController = AppController.getInstance();
        mAppController.getPageManager().addPage(this);

        //EventBus注册
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }

        mAppController.getPageManager().removePage(this);

    }

    @Subscribe
    public void onInvalid(VoidEvent event) {

    }


}
